package com.jrx.anytxn.reporting.service;

import com.jrx.anytxn.common.exception.TxnBizException;
import com.jrx.anytxn.common.exception.TxnException;
import com.jrx.anytxn.customer.entity.CmCustomerAddressInfo;
import com.jrx.anytxn.customer.entity.CmCustomerFirstLevel;
import com.jrx.anytxn.customer.entity.CmCustomerSecondLevel;
import com.jrx.anytxn.transaction.entity.TlThirdPartyPayment;

import java.util.List;

/**
 * 临商文件处理 Service
 *
 * @author liuyang
 * @date 2021-03-13
 */
public interface ILSFileService {

    /**
     * 根据文件名生成对应目录和空文件
     *
     * @param basePath
     * @param fileName
     * @param fileType
     * @param fileSuffix
     * @author liuyang
     * @date 2021-03-13
     */
    void createDirectoriesAndFile(String basePath, String fileName, String fileType, String fileSuffix);

    /**
     * 生成账户信息
     *
     * @param loanId
     * @return String
     * @author liuyang
     * @date 2021-03-13
     */
    String createLSAccountFileMessage(String loanId) throws TxnBizException;

    /**
     * 生成还款流水
     *
     * @param tlThirdPartyPayment
     * @return String
     * @author liuyang
     * @date 2021-03-13
     */
    String createLSThirdPaymentFileMessage(TlThirdPartyPayment tlThirdPartyPayment);

    /**
     * 生成个人信息
     *
     * @param cmCustomerFirstLevel
     * @return String
     * @author liuyang
     * @date 2021-03-13
     */
    String createLSCustFileMessage(CmCustomerFirstLevel cmCustomerFirstLevel) throws TxnBizException;

    /**
     * 生成还款计划
     *
     * @param planId
     * @return String
     * @author liuyang
     * @date 2021-03-13
     */
    String createLSRepaymentFileMessage(Long planId) throws TxnBizException;

    /**
     * 生成特殊交易
     *
     * @param tlThirdPartyPayment
     * @return String
     * @author liuyang
     * @date 2021-03-13
     */
    String createLSSpecialTranFileMessage(TlThirdPartyPayment tlThirdPartyPayment);

    /**
     * 生成对应文件
     *
     * @param messageList
     * @param reportingPath
     * @param fileName
     * @param fileType
     * @param fileSuffix
     * @param fileCharset
     * @throws TxnException
     * @author liuyang
     * @date 2021-03-13
     */
    void generateLSFile(List<String> messageList, String reportingPath, String fileName, String fileType, String fileSuffix, String fileCharset) throws TxnException;

    /**
     * 临商文件合并
     *
     * @param sourcePath
     * @param outPath
     * @throws TxnException
     * @author liuyang
     * @date 2021-03-19
     */
    void mergeLSFile(String sourcePath, String outPath) throws TxnException;

    /**
     * 临商文件传输
     *
     * @param outPath
     * @param ntfsPath
     * @param bizFtypeCode
     * @throws TxnException
     * @author liuyang
     * @date 2021-03-19
     */
    void transLSFile(String outPath, String ntfsPath, String bizFtypeCode) throws TxnException;

    /**
     * 获取客户的详细地址
     *
     * @param customerAddressInfo 客户地址信息
     * @return String
     * @author liuyang
     * @date 2021-03-13
     */
    String getAllAddress(CmCustomerAddressInfo customerAddressInfo);

    /**
     * 征信报送码值映射
     *
     * @param codeType 代码类型
     * @param code     代码
     * @return 映射的码值
     * @author liuyang
     * @date 2021-03-13
     */
    String getICRCode(String codeType, String code);

    /**
     * 临商，根据字节长度，截取字符串
     *
     * @param str 字符串
     * @param len 字节长度
     * @return String
     * @throws TxnBizException
     */
    String getLSLenStr(String str, int len) throws TxnBizException;

    /**
     * 文件合并
     *
     * @param fileType      文件类型
     * @param toDay         日期
     * @param sourceDirPath 源文件目录
     * @param outDirPath    合并文件目录
     * @param fileNames     源文件列表
     * @param fileSuffix    文件后缀
     * @throws TxnException
     */
    void mergeFile(String fileType, String toDay, String sourceDirPath, String outDirPath, List<String> fileNames, String fileSuffix) throws TxnException;
}
